import 'package:qr_code_app/generated/json/base/json_convert_content.dart';
import 'package:qr_code_app/module/user/entity/user_entity.dart';

UserEntity $UserEntityFromJson(Map<String, dynamic> json) {
  final UserEntity userEntity = UserEntity();
  final String? username = jsonConvert.convert<String>(json['username']);
  if (username != null) {
    userEntity.username = username;
  }
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    userEntity.email = email;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    userEntity.avatar = avatar;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    userEntity.nickname = nickname;
  }
  return userEntity;
}

Map<String, dynamic> $UserEntityToJson(UserEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['username'] = entity.username;
  data['email'] = entity.email;
  data['avatar'] = entity.avatar;
  data['nickname'] = entity.nickname;
  return data;
}

extension UserEntityExtension on UserEntity {
  UserEntity copyWith({
    String? username,
    String? email,
    String? avatar,
    String? nickname,
  }) {
    return UserEntity()
      ..username = username ?? this.username
      ..email = email ?? this.email
      ..avatar = avatar ?? this.avatar
      ..nickname = nickname ?? this.nickname;
  }
}